package com.zzc.emotisenseclassroom.controller.upload;

import cn.hutool.core.io.FileUtil;
import com.zzc.common.response.ZzcResponse;
import com.zzc.emotisenseclassroom.common.ResponseCodeEnum;
import com.zzc.emotisenseclassroom.domain.upload.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * Copyright Zzc
 * FileName: FileUploadController
 * Author:   Zzc
 * Date:     2024/5/513:48
 * Description:文件上传控制器
 * hISTORY:
 * <author>  <time>     <version>    <desc>
 * 作者姓名   修改时间       版本号       描述
 * Zzc                   1.0.0
 */
@RestController
@RequestMapping("/file")
public class FileUploadController {
    @Autowired
    private FileUploadService fileUploadService;

    @PostMapping("/uploadimage")
    public ZzcResponse uploadImage(@RequestParam MultipartFile file) throws IOException {
        return ZzcResponse.success(ResponseCodeEnum.UPLOAD_FILE_SUCCESS, fileUploadService.uploadImage(file));
    }

    @PostMapping("/uploadVideo")
    public ZzcResponse uploadVideo(@RequestParam MultipartFile file) throws IOException {
        return ZzcResponse.success(ResponseCodeEnum.UPLOAD_FILE_SUCCESS, fileUploadService.uploadVideo(file));
    }
}
